package com.lft01.thread;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Function: 		ADD FUNCTION.
 * Reason:   		ADD REASON.
 * Date             2020/6/6 13:08
 * <p>
 * Class Name:      NumPrintTest2
 * Package Name:    com.lft.thread
 *
 * @author Laifengting
 * @version 1.0.0
 * @since JDK 8
 */
public class NumPrintTest4 {
	public static void main(String[] args) {
		
		NumPrintTest3 numPrintTest = new NumPrintTest3();
		
		// 1.创建线程池
		ExecutorService pool = Executors.newFixedThreadPool(6);
		
		//2.为线程池中的线程分配任务
		pool.submit(() -> {
			for (int i = 0; i < 5; i++) {
				numPrintTest.print0();
			}
		});
		
		pool.submit(() -> {
			for (int i = 0; i < 5; i++) {
				numPrintTest.print0();
			}
		});
		
		pool.submit(() -> {
			
			for (int i = 0; i < 5; i++) {
				numPrintTest.print1();
			}
		});
		
		pool.submit(() -> {
			for (int i = 0; i < 5; i++) {
				numPrintTest.print1();
			}
		});
		
		// 3.关闭线程池
		pool.shutdown();
	}
}
